{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="{% static 'jquery-1.2.6.js' %}"></script>
    <script>
        function q() {
            var user = $('#user').val()
            if (user.length === 0){
                $('#uu').html('不能为空')
                $('#uu').css('color','red')
            }else {
                $.get('/only/',{'user':user},function (data) {
                    var r = JSON.parse(data)
                    console.log(r.flag);
                    if (r.flag === 1){
                        $('#uu').html('此用户已存在')
                        $('#uu').css('color','red')
                    }else {
                        $('#uu').html('√')
                        $('#uu').css('color','blue')
                    }
                })

            }
        }
    </script>
</head>
<body>
<form action="" method="post">
    <span>用户名：</span><input type="text" name="user" id="user" onblur="q()"><span id="uu"></span>
    <hr>
    <span>密码：</span><input type="text" name="pwd">
    <hr>
    <button>注册</button>
</form>
</body>
</html>